<script>
    //推荐总人数  时间查询
    function searchReference() {

        var referenceyear=$('#referenceyear').val()
        var referencemonth=$('#referencemonth').val()

        var date;
        if(referenceyear&&referencemonth){
            date=referenceyear+'-'+referencemonth;
        }else if(referenceyear){
            date=referenceyear;
        }else if(!referenceyear){

            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;


                layer.msg('请输入年份');
            });

            return false;
        }else if(!referenceyear&&!referencemonth){

            layui.use(['layer', 'form'], function(){
                var layer = layui.layer;


                layer.msg('请选择时间');
            });
            return false;
        }

        // alert(date);return false;


        var ydatareference=[];
        var xdatereference=[];
        var Xunit='';
        $.ajax({
            method: "POST",
            url: "reference",
            data: {'date':date,  '_token':'{{csrf_token()}}'},
            async: false,
            dataType: "",
            success:function (eval) {
                if ( eval.code == '200' ) {
                    var totalRe=0;//推荐总人数
                    $.each(eval.data.reference, function (index, item) {

                        if(referenceyear&&referencemonth){//输入了年 月

                            ydatareference.push(item.count);
                            xdatereference.push(item.registTime.substring(6)) ;
                            Xunit='日';
                            totalRe += parseInt(item.count);


                        }else if(referenceyear){//输入了年
                            xdatereference.push(item.registTime.substring(4)) ;
                            ydatareference.push(item.count);
                            Xunit='月';
                            totalRe += parseInt(item.count);
                        }

                        $('#respan').html(totalRe);

                    })

                    showLineChart(xdatereference,ydatareference,totalRe,Xunit=Xunit,date='',id='main3',title='',titleUnit='');



                } else if ( eval.code == '666' ) {
                    loginFaild();
                }else  {
                    alert('暂无数据')
                }
            }
        });

    }






</script>